package com.example.controller;

import com.example.domain.Student;
import com.example.service.StudentService;
import com.example.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: WJ
 * @CreateTime: 2025-04-23  16:29
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("/students")
public class StudentController {
    @Autowired
    private StudentService studentService;

    /**
     * 获取所有学生信息
     * @return
     */
    @GetMapping("/getAllStudents")
    public Object getAllStudent(){
        List<Student> list = studentService.getAllStudent();
        return AjaxResult.success(list);
    }
    /**
     * 根据id获取学生信息
     * @param id
     * @return
     */
    @GetMapping("/getStudentById/{id}")
    public Object getStudentById(@PathVariable Long id){
        Student student = studentService.getStudentById(id);
        return AjaxResult.success(student);
    }
    /**
     * 根据id获取学生成绩
     * @param id
     * @return
     */
    @GetMapping("/getScoreById/{id}")
    public Object getScoreById(@PathVariable Long id){
        return AjaxResult.success(studentService.getScoreById(id));
    }
    /**
     * 根据id和班级id获取学生排名
     * @param id
     * @param classId
     * @return
     */
    @GetMapping("/getRankByIdAndClassId/{id}/{classId}")
    public Object getRankByIdAndClassId(@PathVariable Long id,@PathVariable Integer classId){
        return AjaxResult.success(studentService.getRankByIdAndClassId(id,classId));
    }
    /**
     * 根据id获取综合信息
     * @param id
     * @return
     */
    @GetMapping("/getComprehensiveInfoById/{id}")
    public Object getComprehensiveInfoById(@PathVariable Long id){
        return AjaxResult.success(studentService.getComprehensiveInfoById(id));
    }

    /**
     * 根据id获取课前信息
     * @param id
     * @return
     */
    @GetMapping("/getBeforeClassInfoById/{id}")
    public Object getBeforeClassInfoById(@PathVariable Long id){
        return AjaxResult.success(studentService.getBeforeClassInfoById(id));
    }
    /**
     * 根据id获取课中信息
     * @param id
     * @return
     */
    @GetMapping("/getDuringClassInfoById/{id}")
    public Object getDuringClassInfoById(@PathVariable Long id){
        return AjaxResult.success(studentService.getDuringClassInfoById(id));
    }
    /**
     * 根据id获取课后信息
     * @param id
     * @return
     */
    @GetMapping("/getAfterClassInfoById/{id}")
    public Object getAfterClassInfoById(@PathVariable Long id){
        return AjaxResult.success(studentService.getAfterClassInfoById(id));
    }
    /**
     * 根据id获取进步信息
     * @param id
     * @return
     */
    @GetMapping("/getAdvancedInfoById/{id}")
    public Object getAdvancedInfoById(@PathVariable Long id){
        return AjaxResult.success(studentService.getAdvancedInfoById(id));
    }
    /**
     * 根据id获取课中评语信息
     * @param id
     * @return
     */
    @GetMapping("/getRemarkInfoById/{id}")
    public Object getRemarkInfoById(@PathVariable Long id){
        return AjaxResult.success(studentService.getRemarkInfoById(id));
    }
}
